package com.biz.primus.ms.commodity.dao.repository.productSort;

import com.biz.primus.ms.base.jpa.repository.CommonJpaRepository;
import com.biz.primus.ms.commodity.dao.po.DepotProductSortItem;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

/**
 * 省下门店商品的排序的子项DAO
 * 
 * @author Nian.Li
 * <br>2016年9月10日
 */
public interface DepotProductSortItemRepository extends CommonJpaRepository<DepotProductSortItem, Long>,JpaSpecificationExecutor<DepotProductSortItem>,DepotProductSortItemDao {
	
	@Query("from DepotProductSortItem d where d.depotProductSort.provinceId=:provinceId order by d.sortVal asc ")
    Page<DepotProductSortItem> findByProvinceId(@Param("provinceId") Integer provinceId, Pageable page);


	@Query("from DepotProductSortItem d where d.depotProductSort.id=:depotProductSortId and d.product.id=:productId order by d.sortVal asc ")
	DepotProductSortItem findByDepotProductSortIdAndProductId(@Param("depotProductSortId") Long depotProductSortId, @Param("productId") Long productId);

}
